﻿var oldRowsIndex = -1;
function AddbgColor() {
    var rows = document.getElementById("tblist").rows;
    if (rows.length > 0) {
        for (var i = 1; i < rows.length; i++) {
            (function (i) {
                var obj = rows[i];
                obj.onclick = function () {
                    var temp = rows[i].cells[0].childNodes[0].value;
                    if (temp == undefined || temp == null) {
                        temp = rows[i].cells[0].childNodes[1].value;
                    }
                    document.getElementById("hdf_Id").value = temp;
                    obj.style.backgroundColor = "#388ECC"; //alert(i % 2);
                    obj.style.color = "#FFFFFF";
                    if (oldRowsIndex != -1 && oldRowsIndex != i) {
                        if (oldRowsIndex % 2 == 0) {
                            rows[oldRowsIndex].style.backgroundColor = "#f5f8fa";
                            rows[oldRowsIndex].style.color = "#000000";
                        }
                        else {
                            rows[oldRowsIndex].style.backgroundColor = "#FFFFFF";
                            rows[oldRowsIndex].style.color = "#000000";
                        }
                    }
                    oldRowsIndex = i;
                };
            })(i)
        }
    }
}

window.onload = function () { AddbgColor(); }  